package Eyjafjalla.power;

import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class WhiteCloudPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:WhiteCloudPower";
    private static final PowerStrings powerStrings;

    public WhiteCloudPower(AbstractCreature owner, int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.updateDescription();
        String path128 = "EyjafjallaResources/img/power/WhiteCloudPower_84.png";
        String path48 = "EyjafjallaResources/img/power/WhiteCloudPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);

        this.type = PowerType.DEBUFF;
    }

    public float atDamageGive(float damage, DamageInfo.DamageType type) {
        if (type == DamageInfo.DamageType.NORMAL) {
            float bl = 1f;
            for(int i =0;i<this.amount;i++)
                bl *= 0.8f;
            return damage*bl;
        } else {
            return damage;
        }
    }

    @Override
    public void onAttack(DamageInfo info, int damageAmount, AbstractCreature target) {
        if(info.type== DamageInfo.DamageType.NORMAL){
            addToBot(new RemoveSpecificPowerAction(this.owner,this.owner,this));
        }
    }

    @Override
    public void updateDescription() {
        float bl = 100;
        for(int i =0;i<this.amount;i++)
            bl *= 0.8f;
        this.description = powerStrings.DESCRIPTIONS[0] + (int)bl + powerStrings.DESCRIPTIONS[1];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}
